/**
 * Created by hhy on 2017/8/10.
 */
var vm = new Vue({
    el:'#ggapp',
    data:{
        tagName:'',
        articleList:[],
        hasPrev:true,
        hasNext:true,
        current:1,
    },
    methods: {
        getArticleList: function(tagName,pageNum){
            $.get(baseURL + "blog/tag/"+tagName+"?pageNum="+pageNum, function(r){
                vm.tagName = tagName;
                var al = r.data;
                for(var index in al){
                    var item = al[index];
                    item.createTime = moment(item.createTime).format('YYYY/MM/DD');
                    vm.articleList.push(item);
                }

                vm.hasPrev = r.current > 1;
                vm.hasNext = r.current < r.pages;
                vm.current = r.current;
                //var sendTime = moment(data.sendTime).format('HH:mm');
                //document.setTitle(r.data.title);
            });
        }
    },
    beforeCreate: function(){

    },
    created: function(){
        //articleList
        var articlePage = getQueryString("page");
        var tagName = getQueryString("tagName");
        if(tagName == null || tagName+"".trim().length == 0){
            location.href = '404.html';
        }
        if(articlePage == null || articlePage+"".trim().length == 0){
            this.getArticleList(tagName,1);
        }else{
            this.getArticleList(tagName,articlePage);
        }
    },
    mounted:function(){

    }
});